package core;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

import dao.ServerTab;
import dao.ServerTabDAO;
import dao.Serverinfo;
import dao.ServerinfoDAO;

public class Email_Autherticator extends Authenticator {
	String username;

	String password ;
	
	private ServerinfoDAO serverinfoDAO;

	public Email_Autherticator() {
		super();
		Serverinfo serverInfo=serverinfoDAO.findById((short) 1);
		username=serverInfo.getServerEmail();
		password=serverInfo.getServerEmailPwd();
	}

	public Email_Autherticator(String user, String pwd) {
		super();
		username = user;
		password = pwd;
	}

	public PasswordAuthentication getPasswordAuthentication() {
		return new PasswordAuthentication(username, password);
	}
}
